<template>
    <div></div>
</template>

<script>
export default {
    data() {
        return {
            params: {}
        }
    },
    mounted() {

        this.params = this.$route.query;
        this.getPayLink();
    },
    methods: {
        // 获取支付链接
        getPayLink() {
            var formData = new FormData();
            for (var key in this.params) {
                formData.append(key, this.params[key]);
            }
            this.$axios.post("/pay", formData)
            .then(res => {
                if(res.data.indexOf('http') === -1) {
                    this.$message({
                        message: res.data,
                        duration: 0,
                        showClose: true
                    })
                } else {
                    window.location.href = res.data
                }
            })
            .catch(err => {
                this.$message({
                    message: '支付接口出错了'
                })
            })
        },
        
    }
 
};
</script>

